﻿using System;

namespace EWS
{
    public struct bpdata
    {
        private int dia, sys;

        public bpdata(int dia, int sys)
        {
            this.dia = dia;
            this.sys = sys;
        }

        public int Dia
        {
            get { return (dia); }
        }

        public int Sys
        {
            get { return sys; }
        }
    }

    public struct measureData
    {
        private int bedNumber;
        private bpdata myBpdata;
        private int resperatoryRate, pulse, oxygenSaturation;
        private float temperature;
        private DateTime creationTime;

        /*
         * use this constructor when receiving data from the database (creationTime value comes from the db)
         */
        public measureData(int bedNumber, bpdata myBpdata, int resperatoryRate, int pulse, float temperature, int oxygenSaturation, DateTime creationTime)
        {
            this.bedNumber = bedNumber;
            this.myBpdata = myBpdata;
            this.resperatoryRate = resperatoryRate;
            this.pulse = pulse;
            this.temperature = temperature;
            this.oxygenSaturation = oxygenSaturation;
            this.creationTime = creationTime;
        }

        /*
         * use this constructor when submitting data to the database (creationTime value comes from the WardClient Software)
         */
        public measureData(int bedNumber, bpdata myBpdata, int resperatoryRate, int pulse, float temperature, int oxygenSaturation)
        {
            this.bedNumber = bedNumber;
            this.myBpdata = myBpdata;
            this.resperatoryRate = resperatoryRate;
            this.pulse = pulse;
            this.temperature = temperature;
            this.oxygenSaturation = oxygenSaturation;
            this.creationTime = DateTime.Now;
        }

        public bpdata bpdata
        {
            get { return myBpdata; }
        }

        public int ResperatoryRate
        {
            get { return resperatoryRate; }
        }

        public int Pulse
        {
            get { return pulse; }
        }

        public float Temperature
        {
            get { return temperature; }
        }

        public int OxygenSaturation
        {
            get { return oxygenSaturation; }
        }

        public DateTime CreationTime
        {
            get { return creationTime; }
        }

        public int BedNumber
        {
            get { return bedNumber; }
        }

        // calculate ward number from bednumber
        public int WardNumber
        {
            get
            {
                int i = bedNumber;
                while (i >= 10)
                {
                    i /= 10;
                }
                return i;
            }
        }
    }
}
